﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for LearnerWordsearch.xaml
    /// </summary>
    public partial class LearnerWordsearch : Page
    {
        WordSearch ws;
        TakeAssessment takeAsmnt;
        MainWindow main;
        
        public LearnerWordsearch(TakeAssessment takeAsmnt)
        {
            InitializeComponent();
            this.takeAsmnt = takeAsmnt;    
        }

        private void takeAssessmentBtn_Click_1(object sender, RoutedEventArgs e)
        {
            TakeAssessment takeAsmntWindow = new TakeAssessment(main);
            takeAsmntWindow.Content = null;
            mainContent.Children.Add(takeAsmntWindow.mainContent);
        }

        private void assessmentProfileBtn_Click_1(object sender, RoutedEventArgs e)
        {
            LearnerAssessmentProfile lrnerAsmntProfileWindow = new LearnerAssessmentProfile();
            lrnerAsmntProfileWindow.Content = null;
            mainContent.Children.Add(lrnerAsmntProfileWindow.mainContent);
        }

        private void searchAssessmentBtn_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void Page_Loaded_1(object sender, RoutedEventArgs e)
        {
            List<String> list = Database.PopulateWordsearch(this, takeAsmnt);
            ws = new WordSearch(list);
            wsViewer.Content = ws.drawWordSearch();
        }

        private void submitWs_Click_1(object sender, RoutedEventArgs e)
        {
            int wordsFound = ws.done();

            if (wordsFound == 1)
            {
                asmntResultLblGrid.Visibility = Visibility.Visible;
                wsViewer.IsEnabled = false;
                wsAsmntResultLbl.Content = ws.resultString;
                Database.SubmitWs(this, ws, main);
            }

            else
            {
                // do nothing
            }
        }
    }
}
